package com.ai.emall.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ai.emall.bean.gbean.ProductSku;
import com.ai.emall.bean.gbean.ProductSkuExample;
import com.ai.emall.dao.gdao.ProductSkuMapper;
import com.ai.emall.service.interfaces.IProductSkuSV;
import com.ai.emall.utils.util.CollectionUtil;
@Service
public class ProductSkuSVImpl implements IProductSkuSV {
	@Autowired
	private ProductSkuMapper productSkuMapper;
	@Override
	public List<ProductSku> getBeansByProductId(Long productId) throws Exception {
		if(productId==null)
			return null;
		ProductSkuExample example = new ProductSkuExample();
		com.ai.emall.bean.gbean.ProductSkuExample.Criteria sql = example.createCriteria();
		sql.andProductIdEqualTo(productId);
		return productSkuMapper.selectByExample(example);
	}

	@Override
	public List<ProductSku> getBeansByProductIds(List<Long> productIds) throws Exception {
		if(CollectionUtil.isEmpty(productIds))
			return null;
		ProductSkuExample example = new ProductSkuExample();
		com.ai.emall.bean.gbean.ProductSkuExample.Criteria sql = example.createCriteria();
		sql.andProductIdIn(productIds);
		return productSkuMapper.selectByExample(example);
	}


}
